package com.navinfo.platform.dataanalysis.dto;

import lombok.Data;

import java.io.Serializable;

@Data
public class EventCache implements Serializable {
    private int gpsDate;
    private int times;
    private int duration;
    private int mileage;
    private int times100km;
    private int firstGpsDate;
    private int currDate;
    private boolean lastStatus;
    private int falseTimes;

    public void incrFalseTimes(){
        ++falseTimes;
    }
    public void incrTimes(){
        times++;
    }

    public void incrTimes(int diff){
        times += diff;
    }

    public void incrDuration(int duration){
        this.duration += duration;
    }

    public void initGpsDate(int gpsDate){
        if(this.gpsDate == 0){
            this.gpsDate = gpsDate;
        }
    }

    public void incrMileage(int mileage){
        this.mileage += mileage;
    }

    public int getDiffDuration(){
        if(gpsDate == 0){
            return 0;
        } else {
            return currDate - gpsDate;
        }
    }

    public int calcDuration(int limit){
        if(gpsDate == 0){
            return 0;
        } else {
            return currDate - gpsDate > limit ? 0 : currDate - gpsDate;
        }
    }

}
